<template lang="pug">
	.row
		.col-md-4.col-md-offset-4
			form
				.form-group(v-bind:class="{'has-error': !status}")
					label 邮箱
					input.form-control(type='email' v-model='email')
				.form-group(v-bind:class="{'has-error': !status}")
					label 密码
					input.form-control(type='password' v-model='password')
				.checkbox
					label
						input(type='checkbox' v-model="remember")
						| 记住我
				div
					a(
						v-link="{name: 'register'}"
						style=`
							padding: 7px 13px;
							display: inline-block;
						`
					) 立即注册？
					button.btn.btn-default.pull-right(@click="submit") 登录


</template>
<script>
	module.exports = {
		mixins: [
			require('mixin/rpc'),
		],
		data () {
			return {
				email   : '',
				password: '',
				remember: false,
				status  : true,
			}
		},
		methods: {
			submit () {
				this.login({
					email   : this.email,
					password: this.password,
					remember: this.remember,
				}).then(res => {
					if (res.data.status === 'success') {
						this.$router.go({
							name: 'index',
						})
					}

					if (res.data.status === 'fail') {
						this.status = false
					}
				})
			},
		},
	}
</script>